package maven.jyhs.com.servlet;


import maven.jyhs.com.proxy.dynamic.CglibProxyFactory;
import maven.jyhs.com.servce.TranstfeSevrce;
import maven.jyhs.com.servce.impl.TranstfeSevrceImpl;


import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

@WebServlet(urlPatterns = "/add")
//@MultipartConfig
public class Add extends HttpServlet {
   TranstfeSevrce t= CglibProxyFactory.createProxy(new TranstfeSevrceImpl());

    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException {
        resp.setContentType("application/json;charset=UTF-8");
        resp.setCharacterEncoding("utf-8");
        String name = req.getParameter("names");
        String shoname = req.getParameter("xlk");
        Integer shokahao = Integer.valueOf(req.getParameter("shokahao"));
        int amount = Integer.parseInt(req.getParameter("amount"));
        int list = t.add(null);
        int i=t.xuogai(amount,shoname,name);
        PrintWriter out = resp.getWriter();
        if (list>0&&i>0){
            out.print(list);
        }
        out.flush();
        out.close();


    }

    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doGet(req, resp);
    }
}
